<?php

header("Access-Control-Allow-Origin: *");
//跳转查询
include_once '../../library/config.php';
include_once '../../model/gponuserlist.php';

$entity = new GponUser();
$list = new GponUser();
$entity->request();

try {

    $neirong = $entity['neirong'];
    $peibis = $entity['peibi'];
    $peibi=(int)$peibis;
    $list->select()->where('shangjifenguangqi=' . "'" . $neirong . "'")->orderby('duanzi asc')->query();
    $arr = array();
    $now = 1;
    while ($list->for_in_rows()) {
        $next = $list['duanzi'];
        while ($now < $next) {
            array_push($arr, [
                "端子" => $now,
                "设备名称" => '',
                "电话号码" => '',
                "宽带号码" => '',
                "sn码" => ''
            ]);
            $now++;
        }
        array_push($arr, [
            "端子" => $list['duanzi'],
            "设备名称" => $list['shebeimingcheng'],
            "电话号码" => $list['tel'],
            "宽带号码" => $list['kuandaizhanghao'],
            "sn码" => $list['sn_code']
        ]);
        $now++;
    }
    while ($now <= $peibi) {
        array_push($arr, [
            "端子" => $now,
            "设备名称" => '',
            "电话号码" => '',
            "宽带号码" => '',
            "sn码" => ''
        ]);
        $now++;
    }
    echo json_encode($arr);
} catch (Exception $exc) {
    echo $list->rsscode($exc);
}


//
//
//
//
////跳转查询
//include_once '../../library/config.php';
//include_once '../../model/gponuserlist.php';
//
//$entity = new GponUser();
//$list = new GponUser();
//$entity->request();
//
//try {
//
//    $neirong = $entity['neirong'];
//    $list->select()->where('shangjifenguangqi=' . "'" . $neirong . "'")->orderby('duanzi asc')->query();
//    $arr = array();
//    $now = 1;
//    while ($list->for_in_rows()) {
//        $next = $list['duanzi'];
//        while ($now < $next) {
//            array_push($arr, [
//                "端子" => $now,
//                "设备名称" => '',
//                "电话号码" => '',
//                "宽带号码" => '',
//                "sn码" => ''
//            ]);
//            $now++;
//        }
//        array_push($arr, [
//            "端子" => $list['duanzi'],
//            "设备名称" => $list['shebeimingcheng'],
//            "电话号码" => $list['tel'],
//            "宽带号码" => $list['kuandaizhanghao'],
//            "sn码" => $list['sn_code']
//        ]);
//        $now++;
//    }
//    echo json_encode($arr);
//} catch (Exception $exc) {
//    echo $list->rsscode($exc);
//}
//
//
//
//
//
//
//
//
//
//////跳转查询
////include_once '../../library/config.php';
////include_once '../../model/gponuserlist.php';
////
////$entity = new GponUser();
////$list = new GponUser();
////$entity->request();
////
////try {
////    
////    $neirong=$entity['neirong'];
////    $list->select()->where('shangjifenguangqi='."'".$neirong."'")->orderby('duanzi asc')->query();
////    $arr=array();
////    while($list->for_in_rows()){
////        array_push($arr, [
////            "端子"=>$list['duanzi'],
////            "设备名称"=>$list['shebeimingcheng'],
////            "电话号码"=>$list['tel'],
////            "宽带号码"=>$list['kuandaizhanghao'],
////            "sn码"=>$list['sn_code']
////        ]);
////    }
////    echo json_encode($arr);
////    
////} catch (Exception $exc) {
////    echo $list->rsscode($exc);
////}
